import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-3,3,50)
y1 = 2*x + 1
y2 = x**2


plt.figure(num="直线图",facecolor='grey',edgecolor='k')
plt.plot(x,y2,color = 'orange',marker="o")
plt.plot(x,y1,color = 'red',linewidth=1.5,linestyle='--')
#设置x/y轴
plt.xlim((-1.5,2.5))
plt.xlabel("I am x")

plt.ylim((-1.5,3.5))
plt.ylabel("I am Y")

plt.xticks([-1,0,1,2])
plt.yticks([-1.0,1,2,3])

#抓取图表的边框
ax = plt.gca()

#选取某一个边框，进行设置
ax.spines['right'].set_color("none")
ax.spines['top'].set_color("none")

ax.spines['left'].set_color("blue")
ax.spines['bottom'].set_color("green")

#设置轴到指定位置
ax.spines['bottom'].set_position(('data',0))
ax.spines['left'].set_position(('data',0))

plt.show()
